package com.qk.mapper;

import com.qk.dto.ActivityDto;
import com.qk.entity.Activity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * ClassName: ActivityMapper
 * Package: com.qk.mapper
 * Description:
 *
 * @Author zt
 * @Create 2025/7/30 21:00
 * @Version 1.0
 */
@Mapper
public interface ActivityMapper {

    /*
    1.分页列表查询
     */
    List<Activity> selectByCondition(ActivityDto activityDto);

    /*
    2.删除活动
     */
    @Delete("delete from activity where id = #{id}")
    void delete(Integer id);

    /*
    3.添加活动
    */
    @Insert("insert into activity (channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time) values" +
            "(#{channel}, #{name}, #{startTime}, #{endTime}, #{description}, #{type}, #{discount}, #{voucher}, #{createTime}, #{updateTime})")
    void add(Activity activity);

    /*
    4.根据ID查询
     */
    @Select("select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity where id = #{id}")
    Activity getById(Integer id);

    /*
    5.修改活动
     */
    void update(Activity activity);

    /*
    6.查询指定类型的活动
     */
    @Select("select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity where type = #{type}")
    List<Activity> listByType(Integer type);

    /*
    7.查询所有活动
     */
    @Select("select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity")
    List<Activity> list();
}
